#ifndef __C_STD_H__
#define __C_STD_H__

#include "./../config.h"

#ifdef TEST_DBG_WIN32
#include <stdio.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifdef TEST_DBG_WIN32
#define PACKED
// compile error in font implementation
#define inline
#else
#define PACKED	__attribute__((gcc_struct, packed))
#endif

#ifndef NULL
#define NULL	(0)
#endif

#ifndef __cplusplus
typedef int bool;
#endif

typedef char* va_list;
typedef unsigned int uint;
typedef unsigned int size_t;
typedef unsigned short ushort;

#ifndef true
#define true	(1)
#endif

#ifndef false
#define	false	(0)
#endif

#define KERNEL_START			(0xC0000000)
#define KERNEL_BASE				(0xC0110000)
#define KRNL_LOW_MEM_BOUNDARY	(0xC1000000)

#define PAGE_SIZE		(4096)
#define PAGE_SZ			(4096)
#define PAGE_SHIFT		(12)

// common error definition
#define ERR_BAD_PARAMETERS		(1)
#define ERR_OUT_OF_RANGE		(2)
#define ERR_NOMEMORY			(3)
#define ERR_BUSY				(4)
#define ERR_LOGIC				(5)
#define ERR_RESLIMIT			(6)
#define ERR_SYS_NOT_READY		(7)
#define ERR_USER				(10000)

#define ERR_OTHER(v)		(ERR_USER + v)

#ifndef TEST_DBG_WIN32

// function definition (basics)
void* memset(void *dst, int val, size_t sz);
void* memcpy(void *dst, const void *src, size_t sz);
void* memmove(void *dst, const void *src, size_t sz);

size_t strlen(const char *str);
int strcmp(const char *str1, const char *str2);
char *strcpy(char* dest, const char *src);
int strncmp(const char *str1, const char *str2, size_t maxcnt);
char *strcat(char *dest, const char *src);

int printk(const char * fmt, ...);
int sprintf(char * buf, const char *fmt, ...);
int vsprintf(char *buf, const char *fmt, va_list args);

#else

#define printk	printf

#endif

#include "debug.h"

#ifdef __cplusplus
}
#endif
#endif
/* EOF */

